package com.hundsun.yr.universal.library.view.gallery;

import android.os.Build;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;

public class VersionDiffUtils{
    
	
	/**
	 * X轴缩放
	 * @param view
	 * @param f 缩放系数
	 */
    public static void scaleX(View view, float f) {
        if (view == null)
            return;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            view.setScaleX(f);
            view.setAlpha(f);
        } else {
            ScaleAnimation animation =new ScaleAnimation(f, f, f, f, 
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
            animation.setDuration(0);
            animation.setFillAfter(true);
            view.startAnimation(animation);
        }
    }
    
    
    /**
     * Y轴缩放
     * @param view
     * @param f 缩放系数
     */
    public static void scaleY(View view, float f) {
    	if (view == null)
    		return;
    	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    		view.setScaleY(f);
    		view.setAlpha(f);
    	} else {
    		ScaleAnimation animation =new ScaleAnimation(f, f, f, f, 
    				Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
    		animation.setDuration(0);
    		animation.setFillAfter(true);
    		view.startAnimation(animation);
    	}
    }
    
    /**
     * 透明度
     * @param view
     * @param f 透明系数
     */
    public static void setAlpha(View view, float f) {
        if (view == null)
            return;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            view.setScaleX(f);
            view.setAlpha(f);
        }
        
    }
}
